package com.ss.android.article.base.feature.model;

import android.text.TextUtils;

import com.bytedance.article.b.a.GsonDependManager;
import com.bytedance.common.utility.Logger;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.feed.c.FeedDownloadAppAd;
import com.ss.android.article.base.feature.feed.c.FilterWord;
import com.ss.android.article.base.feature.feed.c.b;
import com.ss.android.article.common.entity.wenda.WendaEntity;
import com.ss.android.article.common.entity.wenda.WendaEntity.Answer;
import com.ss.android.article.common.entity.wenda.WendaEntity.Question;
import com.ss.android.article.common.entity.wenda.WendaEntity.WendaExtra;
import com.ss.android.b.a.BaseAdsData;
import com.ss.android.common.util.json.JsonUtil;
import com.ss.android.image.model.ImageInfo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import inline.TempBean;

public final class CellRef {
    public int cellFlag = 267;
    public boolean B;
    public long C;
    public boolean D;
    public Article article;
    public i F = null;
    public DownloadAppAd downloadAppAd;
    public FeedCallAppAd feedCallAppAd;
    public AdsData embeddedAd;
    public WendaEntity wendaEntity;
    public long userRepinTime;
    public String label;
    public int labelStyle;
    public int[] title;
    public int[] _abstract;
    public long adId;//ad_id
    public int Q;
    public String adLabel;
    public List adTrackUrl;
    public List adClickTrackUrlList;
    public List statUrlList;
    public int videoChannelAdType = 0;//video_channel_ad_type
    public long expireSeconds = 0;
    public long adFetchTime = 0;
    public boolean adHasExpire = false;
    public String appendExtraData;
    public static String VALID_CELL_TYPES_STR;
    private String aA;
    private String aB;
    private String slotId;
    private int aD;
    private long aE;
    private ImageInfo sourceIconNight;
    public long goDetailCount;
    public boolean ab = false;
    public List<CellRef> ac;
    public boolean ad;
    public ImageInfo sourceIcon;
    public TempBean af;
    public String infoDesc;
    public boolean reuseItem;
    public long readDate;
    public long pushDate;
    public String readHeadText;
    public long readCountcount;
    public long pushCount;
    public String pushHeadText;
    private static int[] ao = new int[]{0, 3, 9, 10, 1, 32};
    private static int[] VALID_CELL_TYPE_ARR = new int[]{10, 16, 30, 36, 43, 44};
    private boolean showDislike = false;
    private boolean isStick;
    private String source;
    private String reason;
    private String recommendUrl;
    private String sourceDesc;
    private String sourceDescOpenUrl;
    private int cellLayoutStyle = 1;
    private int tip;
    private int az;
    public int cellType;//cell_type  10,16: ads 30:LbsAd   36:WendaEntity  -11 :recent read  -10: feed mask -1:last_read_notify
    public JSONObject logPb;
    public String cellId;
    public String category;
    public long cateBehotTime;
    public long cateCursor;
    public String logExtra;
    public String actionExtra;
    public final List<FilterWord> filterWordList = new ArrayList();
    public long readTs;
    public boolean l;
    public boolean m;
    public int videoStyle = -1;
    public int stickStyle;
    public String stickLabel;
    public int galleryStyle;
    public String sourceOpenUrl;
    public String sourceAvatar;
    public int sourceIconStyle;
    public String subTitle;
    public List actionList;
    public boolean isSubscribe;
    public String verifiedContent;
    public int userVerified;
    public int readCount;

    static {
        Integer[] arr = new Integer[6];
        for (int i = 0; i < 6; ++i) {
            arr[i] = Integer.valueOf(VALID_CELL_TYPE_ARR[i]);
        }
        VALID_CELL_TYPES_STR = TextUtils.join(",", arr);
    }

    public CellRef(String category, long cateBehotTime, Article article) {
        this.cellType = 0;
        this.category = category;
        this.cateBehotTime = cateBehotTime;
        this.userRepinTime = article.userRepinTime;
        this.cellId = article.groupId + "-" + category;
        this.article = article;
        Article.a v0 = article.ao;
        if (v0 != null) {
            this.tip = v0.tip;
            this.adId = v0.adId;
            this.adLabel = v0.adLabel;
            this.adTrackUrl = v0.adTrackUrl;
            this.aA = v0.d;
            this.adClickTrackUrlList = v0.adClickTrackUrlList;
            this.aB = v0.f;
            this.title = v0.title;
            this._abstract = v0._abstract;
            this.goDetailCount = v0.goDetailCount;
            this.label = v0.label;
            this.labelStyle = v0.labelStyle;
        }
    }

    public CellRef(int cellType, String category, long cateBehotTime) {
        this(cellType);
        this.category = category;
        this.cateBehotTime = cateBehotTime;
    }

    public CellRef(int cellType) {
        this.cellType = cellType;
        this.cellId = "";
        this.article = null;
        this.category = "";
        this.ac = new ArrayList();
    }

    public static void copy(CellRef dst, CellRef origin) {
        if (dst != origin && dst != null && origin != null) {
            dst.cateBehotTime = origin.cateBehotTime;
            dst.tip = origin.tip;
            dst.adId = origin.adId;
            dst.adLabel = origin.adLabel;
            dst.adTrackUrl = origin.adTrackUrl;
            dst.aA = origin.aA;
            dst.adClickTrackUrlList = origin.adClickTrackUrlList;
            dst.aB = origin.aB;
            dst.title = origin.title;
            dst._abstract = origin._abstract;
            dst.goDetailCount = origin.goDetailCount;
            dst.label = origin.label;
            dst.labelStyle = origin.labelStyle;
            dst.logExtra = origin.logExtra;
            dst.actionExtra = origin.actionExtra;
            dst.Q = origin.Q;
            dst.slotId = origin.slotId;
            dst.feedCallAppAd = origin.feedCallAppAd;
            dst.appendExtraData = origin.appendExtraData;
            dst.af = origin.af;
            dst.videoStyle = origin.videoStyle;
            dst.cellFlag = origin.cellFlag;
            dst.sourceIcon = origin.sourceIcon;
            dst.sourceIconNight = origin.sourceIconNight;
            dst.isStick = origin.isStick;
            dst.aD = origin.aD;
            dst.aE = origin.aE;
            dst.stickLabel = origin.stickLabel;
            dst.stickStyle = origin.stickStyle;
            dst.galleryStyle = origin.galleryStyle;
            dst.statUrlList = origin.statUrlList;
            dst.sourceAvatar = origin.sourceAvatar;
            dst.sourceOpenUrl = origin.sourceOpenUrl;
            dst.reason = origin.reason;
            dst.recommendUrl = origin.recommendUrl;
            dst.source = origin.source;
            dst.sourceDesc = origin.sourceDesc;
            dst.sourceDescOpenUrl = origin.sourceDescOpenUrl;
            dst.subTitle = origin.subTitle;
            dst.actionList = origin.actionList;
            dst.sourceIconStyle = origin.sourceIconStyle;
            dst.az = origin.az;
            dst.videoChannelAdType = origin.videoChannelAdType;
            dst.logPb = origin.logPb;
            if (origin.readDate > 0L) {
                dst.readDate = origin.readDate;
            }

            if (origin.pushDate > 0L) {
                dst.pushDate = origin.pushDate;
            }

            if (origin.readCountcount > 0L) {
                dst.readCountcount = origin.readCountcount;
            }

            if (origin.pushCount > 0L) {
                dst.pushCount = origin.pushCount;
            }

            if (origin.readHeadText != null) {
                dst.readHeadText = origin.readHeadText;
            }

            if (origin.pushHeadText == null) {
                return;
            }

            dst.pushHeadText = origin.pushHeadText;
        }
    }

    public static boolean isValidCellType(int cellType) {
        return Arrays.binarySearch(VALID_CELL_TYPE_ARR, cellType) >= 0;
    }

    public static boolean extractFromJO(CellRef cellRef, JSONObject jo, boolean arg15) {
        boolean v0_2;
        JSONArray filterWordsJO;
        JSONArray v1_6;
        int v1_5;
        JSONObject v1_2;
        JSONObject v0_1;
        int v12 = -1;
        long v8 = 0;
        ImageInfo v2 = null;
        int v4 = 0;
        if (cellRef != null && jo != null) {
            String v1 = cellRef.appendExtraData;
            try {
                if (!android.support.design.a.isTextEmpty(v1)) {
                    v0_1 = new JSONObject(v1);
                } else {
                    v0_1 = null;
                }
                if (v0_1 != null) {

                } else {
                    v0_1 = new JSONObject();
                }
                cellRef.sourceIcon = null;
                cellRef.sourceIconNight = null;

                if (jo.has("source_icon")) {
                    JSONObject sourceIcon = arg15 ? jo.getJSONObject("source_icon") : new JSONObject(jo.optString("source_icon"));
                    cellRef.sourceIcon = ImageInfo.fromJson(sourceIcon, false);
                    a(v0_1, "source_icon", sourceIcon.toString());
                }
            } catch (JSONException v0) {
                label_139:
                Logger.d("CellRef", "exception in appendExtraData : " + v0.toString());
                v0_1 = new JSONObject();
            }
            if (!jo.has("source_icon_night")) {

            } else {
                try {
                    JSONObject sourceIconNight = arg15 ? jo.getJSONObject("source_icon_night") : new JSONObject(jo.optString("source_icon_night"));
                    cellRef.sourceIconNight = ImageInfo.fromJson(sourceIconNight, false);
                    a(v0_1, "source_icon_night", sourceIconNight.toString());
                } catch (JSONException v1_1) {
                    Logger.e("CellRef", "exception in extractSourceIcon : " + v1_1.toString());
                }
            }

            if (jo.has("source_open_url")) {
                String sourceOpenUrl = jo.optString("source_open_url");
                cellRef.sourceOpenUrl = sourceOpenUrl;
                a(v0_1, "source_open_url", sourceOpenUrl);
            }

            if (jo.has("source_avatar")) {
                String sourceAvatar = jo.optString("source_avatar");
                cellRef.sourceAvatar = sourceAvatar;
                a(v0_1, "source_avatar", sourceAvatar);
            }

            try {
                boolean showDislike;
                if (!jo.has("show_dislike")) {
                    showDislike = false;
                } else if (!jo.optBoolean("show_dislike")) {
                    showDislike = true;
                } else {
                    showDislike = false;
                }
                cellRef.showDislike = showDislike;
                long adFetchTime = arg15 ? System.currentTimeMillis() / 1000 : jo.optLong("ad_fetch_time");
                cellRef.adFetchTime = adFetchTime;
                long expireSeconds = jo.optLong("expire_seconds") > v8 ? jo.optLong("expire_seconds") : v8;
                cellRef.expireSeconds = expireSeconds;
                boolean adHasExpire = (!arg15) && jo.optInt("ad_has_expire") > 0;
                cellRef.adHasExpire = adHasExpire;
                appendExtraData(cellRef, "show_dislike", String.valueOf(cellRef.showDislike));
                appendExtraData(cellRef, "expire_seconds", cellRef.expireSeconds);
                appendExtraData(cellRef, "ad_fetch_time", cellRef.adFetchTime);
                appendExtraData(cellRef, "ad_has_expire", cellRef.adHasExpire ? 1 : 0);
                if (!arg15) {
                    String v5 = jo.optString("filter_words");
                    if (!android.support.design.a.isTextEmpty(v5)) {
                        v1_6 = new JSONArray(v5);
                    } else {
                        v1_6 = null;
                    }
                    filterWordsJO = v1_6;
                } else {
                    filterWordsJO = jo.optJSONArray("filter_words");
                }
                if (filterWordsJO == null) {

                } else {
                    cellRef.filterWordList.clear();
                    v1_5 = 0;
                    while (true) {
                        if (v1_5 >= filterWordsJO.length()) {
                            break;
                        }
                        JSONObject jsonObject = filterWordsJO.optJSONObject(v1_5);
                        if (jsonObject != null) {
                            String id = jsonObject.optString("id");
                            String name = jsonObject.optString("name");
                            boolean isSelected = jsonObject.optBoolean("is_selected");
                            if (!android.support.design.a.isTextEmpty(id) && !android.support.design.a.isTextEmpty(name)) {
                                cellRef.filterWordList.add(new FilterWord(id, name, isSelected));
                            }
                        }
                        ++v1_5;
                        continue;
                    }

                    try {
                        a(v0_1, "filter_words", filterWordsJO.toString());
                    } catch (Exception v1_3) {
                        label_515:
                        Logger.e("CellRef", "exception in extractFilterWords : " + v1_3.toString(), ((Throwable) v1_3));
                    }
                }
            } catch (Exception v1_3) {
                v1_3.printStackTrace();
            }

            if (jo.has("is_stick")) {
                cellRef.isStick = jo.optBoolean("is_stick");
                a(v0_1, "is_stick", Boolean.valueOf(cellRef.isStick));
            } else {
                cellRef.isStick = false;
            }

            if (jo.has("video_style")) {
                cellRef.videoStyle = jo.optInt("video_style");
                a(v0_1, "video_style", Integer.valueOf(cellRef.videoStyle));
            } else {
                cellRef.videoStyle = v12;
            }

            if (jo.has("stick_style")) {
                cellRef.stickStyle = jo.optInt("stick_style");
                a(v0_1, "stick_style", Integer.valueOf(cellRef.stickStyle));
            } else {
                cellRef.stickStyle = v12;
            }

            if (jo.has("stick_label")) {
                cellRef.stickLabel = jo.optString("stick_label", "");
                a(v0_1, "stick_label", cellRef.stickLabel);
            } else {
                cellRef.stickLabel = "";
            }

            if (jo.has("gallary_style")) {
                cellRef.galleryStyle = jo.optInt("gallary_style", 0);
                a(v0_1, "gallary_style", Integer.valueOf(cellRef.galleryStyle));
            } else {
                cellRef.galleryStyle = 0;
            }

            if (jo.has("tip")) {
                cellRef.tip = jo.optInt("tip");
                a(v0_1, "tip", Integer.valueOf(cellRef.tip));
            }

            cellRef.reason = jo.optString("reason");
            cellRef.recommendUrl = jo.optString("recommend_url");
            cellRef.source = jo.optString("source");
            cellRef.sourceDesc = jo.optString("source_desc");
            cellRef.sourceDescOpenUrl = jo.optString("source_desc_open_url");
            cellRef.subTitle = jo.optString("sub_title");
            cellRef.actionList = JsonUtil.a(jo.optJSONArray("action_list"), b.class);
            cellRef.sourceIconStyle = jo.optInt("source_icon_style");
            cellRef.isSubscribe = jo.optBoolean("is_subscribe", false);
            cellRef.verifiedContent = jo.optString("verified_content");
            cellRef.userVerified = jo.optInt("user_verified");
            cellRef.readCount = jo.optInt("read_count");
            try {
                if (jo != null) {

                    if (jo.has("reason")) {
                        label_283:
                        v0_1.put("reason", cellRef.reason);
                    }
                } else {
                    v0_1.put("reason", cellRef.reason);
                }

                if (jo == null || (jo.has("recommend_url"))) {
                    v0_1.put("recommend_url", cellRef.recommendUrl);
                }

                if (jo == null || (jo.has("source"))) {
                    v0_1.put("source", cellRef.source);
                }

                if (jo == null || (jo.has("is_subscribe"))) {
                    v0_1.put("is_subscribe", cellRef.isSubscribe);
                }

                if (jo == null || (jo.has("source_desc"))) {
                    v0_1.put("source_desc", cellRef.sourceDesc);
                }

                if (jo == null || (jo.has("source_desc_open_url"))) {
                    v0_1.put("source_desc_open_url", cellRef.sourceDescOpenUrl);
                }

                if (jo == null || (jo.has("sub_title"))) {
                    v0_1.put("sub_title", cellRef.subTitle);
                }

                if (jo == null || (jo.has("action_list"))) {
                    v0_1.put("action_list", JsonUtil.b(cellRef.actionList));
                }

                if (jo != null && !jo.has("source_icon_style")) {
                } else {
                    v0_1.put("source_icon_style", cellRef.sourceIconStyle);
                }
            } catch (JSONException v1_1) {
                Logger.d("CellRef", "exception in appendExtraData : " + v1_1.toString());
            }

            if ((com.ss.android.article.base.utils.c.a.a()) || (Logger.debug())) {
                AppData.getInstance();
            }

            cellRef.cellFlag = jo.optInt("cell_flag", 267);
            cellRef.cellLayoutStyle = jo.optInt("cell_layout_style", 1);
            if (arg15) {
                a(v0_1, "cell_flag", Integer.valueOf(cellRef.cellFlag));
                a(v0_1, "cell_layout_style", Integer.valueOf(cellRef.cellLayoutStyle));
            }

            if (jo.has("log_extra")) {
                String logExtra = jo.optString("log_extra");
                cellRef.logExtra = logExtra;
                a(v0_1, "log_extra", logExtra);
            }

            if (jo.has("action_extra")) {
                String actionExtra = jo.optString("action_extra");
                cellRef.actionExtra = actionExtra;
                a(v0_1, "action_extra", actionExtra);
            }

            if (jo.has("info_desc")) {
                String infoDesc = jo.optString("info_desc");
                cellRef.infoDesc = infoDesc;
                a(v0_1, "info_desc", infoDesc);
            }

            if (cellRef.article != null && (jo.has("ad_button"))) {
                JSONObject adButton = jo.optJSONObject("ad_button");
                FeedDownloadAppAd v5_2 = new FeedDownloadAppAd();
                v5_2.initWithJO(adButton);
                if (v5_2.id <= v8 && cellRef.article.ao != null) {
                    v5_2.id = cellRef.article.ao.adId;
                } else if (v5_2.id <= v8 && cellRef.adId > v8) {
                    v5_2.id = cellRef.adId;
                }

                if (android.support.design.a.isTextEmpty(v5_2.logExtra)) {
                    v5_2.logExtra = cellRef.logExtra;
                }

                cellRef.article.aF = v5_2;
                a(v0_1, "ad_button", adButton);
            }

            if (jo.has("label")) {
                cellRef.label = jo.optString("label");
                a(v0_1, "label", cellRef.label);
            }

            if (jo.has("label_style")) {
                cellRef.labelStyle = jo.optInt("label_style");
                a(v0_1, "label_style", Integer.valueOf(cellRef.labelStyle));
            }

            if (jo.has("ad_label")) {
                cellRef.adLabel = jo.optString("ad_label");
                a(v0_1, "ad_label", cellRef.adLabel);
            }

            if (jo.has("ad_track_url")) {
                String adTrackUrl = jo.optString("ad_track_url");
                cellRef.adTrackUrl = BaseAdsData.a(adTrackUrl);
                a(v0_1, "ad_track_url", adTrackUrl);
            }

            if (jo.has("ad_click_track_url")) {
                String adClickTrackUrl = jo.optString("ad_click_track_url");
                cellRef.adClickTrackUrlList = BaseAdsData.a(adClickTrackUrl);
                a(v0_1, "ad_click_track_url", adClickTrackUrl);
            }

            if (jo.has("slot_id")) {
                cellRef.slotId = jo.optString("slot_id");
                a(v0_1, "slot_id", cellRef.slotId);
            } else {
                cellRef.slotId = "";
            }

            if (jo.has("video_channel_ad_type")) {
                cellRef.videoChannelAdType = jo.optInt("video_channel_ad_type", 0);
                a(v0_1, "video_channel_ad_type", Integer.valueOf(cellRef.videoChannelAdType));
            }

            if (jo.has("log_pb")) {
                String logPb = jo.optString("log_pb");
                try {
                    cellRef.logPb = new JSONObject(logPb);
                } catch (JSONException v1_1) {
                }

                a(v0_1, "log_pb", cellRef.logPb);
            }

            JSONArray ja = jo.optJSONArray("stat_url_list");
            if (ja != null) {
                int v5_3 = ja.length();
                ArrayList v6_3 = new ArrayList(v5_3);
                while (v4 < v5_3) {
                    String v7 = ja.optString(v4, null);
                    if (v7 != null && v7.length() > 0) {
                        v6_3.add(v7);
                    }

                    ++v4;
                }

                cellRef.statUrlList = v6_3;
                a(v0_1, "stat_url_list", ja);
            }

            cellRef.appendExtraData = v0_1.toString();
            v0_2 = true;
        } else {
            v0_2 = false;
        }

        return v0_2;
    }

    public static void appendExtraData(CellRef cellRef, String key, int value) {
        if (cellRef != null && !android.support.design.a.isTextEmpty(key)) {
            String extraData = cellRef.appendExtraData;
            JSONObject jo = null;
            try {
                if (!android.support.design.a.isTextEmpty(extraData)) {
                    jo = new JSONObject(extraData);
                }

                if (jo == null) {
                    jo = new JSONObject();
                }

                jo.put(key, value);
                cellRef.appendExtraData = jo.toString();
            } catch (JSONException v0_1) {
                Logger.d("CellRef", "exception in appendExtraData : " + v0_1.toString());
            }
        }
    }

    public final boolean a() {
        return this.cellType == 0;
    }

    public final void appendReadTs(long ts) {
        if (ts > 0) {
            this.readTs = ts;
            appendExtraData(this, "read_time_stamp", String.valueOf(System.currentTimeMillis()));
        }
    }

    public static boolean extractArticle(CellRef cellRef, JSONObject jo) {
        if (jo == null) {
            return false;
        }

        if (cellRef.cellType != 0) {
            return false;
        }

        try {
            Article article = JsonUtil.extractObjectFromJson(jo, Article.class);
            if (article == null) {
                return false;
            }

            cellRef.article = article;
            extractFromJO(cellRef, jo, true);
            if ((cellRef.isSubscribe) && cellRef.article.mediaInfo != null && cellRef.article.mediaInfo.entryItem != null) {
                cellRef.article.mediaInfo.entryItem.setSubscribed(cellRef.isSubscribe);
            }

            cellRef.cellId = article.groupId + "-" + cellRef.category;
            cellRef.userRepinTime = article.userRepinTime;
            Article.a v0_3 = article.ao;
            if (v0_3 != null) {
                cellRef.tip = v0_3.tip;
                cellRef.adId = v0_3.adId;
                cellRef.adLabel = v0_3.adLabel;
                cellRef.adTrackUrl = v0_3.adTrackUrl;
                cellRef.aA = v0_3.d;
                cellRef.adClickTrackUrlList = v0_3.adClickTrackUrlList;
                cellRef.aB = v0_3.f;
                cellRef.title = v0_3.title;
                cellRef._abstract = v0_3._abstract;
                cellRef.goDetailCount = v0_3.goDetailCount;
                cellRef.label = v0_3.label;
                cellRef.labelStyle = v0_3.labelStyle;
            }

            String adData = jo.optString("ad_data");
            if (!android.support.design.a.isTextEmpty(adData)) {
                JSONObject jsonObject = new JSONObject(adData);
                jsonObject.put("log_extra", jo.optString("log_extra"));
                extractAd(cellRef, jsonObject, true);
            }
        } catch (Exception e) {
            Logger.e("CellRef", "exception in extractArticle : " + e.toString());
            return false;
        }

        return true;
    }

    private static void appendExtraData(CellRef arg4, String arg5, long arg6) {
        if (arg4 != null && !android.support.design.a.isTextEmpty(arg5)) {
            String v1 = arg4.appendExtraData;
            JSONObject v0 = null;
            try {
                if (!android.support.design.a.isTextEmpty(v1)) {
                    v0 = new JSONObject(v1);
                }

                if (v0 == null) {
                    v0 = new JSONObject();
                }

                v0.put(arg5, arg6);
                arg4.appendExtraData = v0.toString();
            } catch (JSONException v0_1) {
                Logger.d("CellRef", "exception in appendExtraData : " + v0_1.toString());
            }
        }
    }

    private static void appendExtraData(CellRef cellRef, String arg5, String arg6) {
        if (cellRef != null && !android.support.design.a.isTextEmpty(arg5) && arg6 != null) {
            String v1 = cellRef.appendExtraData;
            JSONObject v0 = null;
            try {
                if (!android.support.design.a.isTextEmpty(v1)) {
                    v0 = new JSONObject(v1);
                }

                if (v0 == null) {
                    v0 = new JSONObject();
                }
                v0.put(arg5, arg6);
                cellRef.appendExtraData = v0.toString();
            } catch (JSONException v0_1) {
                Logger.d("CellRef", "exception in appendExtraData : " + v0_1.toString());
            }
        }
    }

    private static void a(JSONObject arg1, String arg2, Object arg3) {
        if (arg3 != null) {
            try {
                arg1.put(arg2, arg3);
            } catch (JSONException v0) {
                v0.printStackTrace();
            }
        }
    }

    public static boolean extractAd(CellRef cellRef, JSONObject jo, boolean arg7) {
        boolean v0 = false;
        if (cellRef != null && jo != null) {
            try {
                String type = jo.optString("type");
                int v1_1 = -1;
                if ("app".equals(type)) {
                    v1_1 = 1;
                } else if ("web".equals(type)) {
                    v1_1 = 2;
                } else if ("action".equals(type)) {
                    v1_1 = 3;
                }

                switch (v1_1) {
                    case 1: {
                        return extractAppAd(cellRef, jo, arg7);
                    }
                    case 3: {
                        return extractActionAd(cellRef, jo, arg7);
                    }
                }
                return v0;
            } catch (Exception e) {
                Logger.e("CellRef", "exception in extractAd" + e.toString());
            }
        }
        return v0;
    }

    public static boolean b(int arg5) {
        boolean v0 = false;
        int[] v2 = ao;
        int v3 = v2.length;
        int v1 = 0;
        while (v1 < v3) {
            if (v2[v1] == arg5) {
                v0 = true;
            } else {
                ++v1;
                continue;
            }

            return v0;
        }

        return v0;
    }

    public final boolean isHot() {
        return (this.tip & 1) > 0;
    }

    public static boolean extractWendaEntity(CellRef cellRef, JSONObject jsonObject) {
        if (cellRef == null || cellRef == null) {
            return false;
        } else {
            WendaEntity wendaEntity = new WendaEntity();
            Question question = GsonDependManager.getInstance().fromJson(jsonObject.optString("question"), Question.class);
            Answer answer = GsonDependManager.getInstance().fromJson(jsonObject.optString("answer"), Answer.class);
            WendaExtra wendaExtra = GsonDependManager.getInstance().fromJson(jsonObject.optString("extra"), WendaExtra.class);
            wendaEntity.question = question;
            wendaEntity.answer = answer;
            wendaEntity.extra = wendaExtra;
            wendaEntity.id = jsonObject.optLong("id");
            wendaEntity.cursor = jsonObject.optLong("cursor");
            wendaEntity.behot_time = jsonObject.optLong("behot_time");
            wendaEntity.cell_type = jsonObject.optInt("cell_type");
            cellRef.cellId = wendaEntity.id + "-" + cellRef.category;
            cellRef.wendaEntity = wendaEntity;
            cellRef.appendExtraData = jsonObject.toString();
            return true;
        }
    }

    public static boolean extractOther(CellRef cellRef, JSONObject jsonObject) {
        try {
            switch (cellRef.cellType) {
                case 10:
                case 16:
                    return extractAd(cellRef, jsonObject, false);
                case 30:
                    return extractLbsAd(cellRef, jsonObject, false);
                case 36:
                    return extractWendaEntity(cellRef, jsonObject);
            }
            return false;


        } catch (Exception e) {
            Logger.e("CellRef", "exception in extractOther" + e.toString());
            return false;
        }
    }

    public final boolean isRecommend() {
        return (this.tip & 2) > 0;
    }

    public static boolean extractAppAd(CellRef cellRef, JSONObject jsonObject, boolean appendExtra) {
        int v4 = 10;
        boolean v0 = false;
        if (cellRef != null && jsonObject != null) {
            if (cellRef.cellType != v4) {
                if (cellRef.cellType == 0) {
                } else {
                    return v0;
                }
            }

            try {
                int displayType = jsonObject.optInt("display_type");
                if (!AppAd.a(displayType)) {
                    return v0;
                }

                DownloadAppAd downloadAppAd = new DownloadAppAd(displayType);
                downloadAppAd.initWithJO(jsonObject);
                extractSourceIcon(cellRef, jsonObject, appendExtra);
                extractFilterWords(cellRef, jsonObject, appendExtra);
                extractSourceOpenUrl(cellRef, jsonObject);
                extractSourceAvatar(cellRef, jsonObject);
                appendExtraData(cellRef, jsonObject);
                if (!downloadAppAd.isValid()) {
                    return v0;
                }

                cellRef.downloadAppAd = downloadAppAd;
                cellRef.adId = jsonObject.optLong("id");
                if (cellRef.cellType == v4) {
                    String adId = cellRef.adId > 0 ? String.valueOf(cellRef.adId) : "";
                    cellRef.cellId = adId;
                    cellRef.cateBehotTime = jsonObject.optLong("behot_time");
                    cellRef.logExtra = jsonObject.optString("log_extra");
                    cellRef.actionExtra = jsonObject.optString("action_extra");
                    cellRef.appendExtraData = jsonObject.toString();
                    extractCellLayoutStyle(cellRef, jsonObject, appendExtra);
                } else {
                    if (cellRef.cellType != 0) {
                    } else {
                        appendExtraData(cellRef, "ad_data", jsonObject.toString());
                        cellRef.Q = 3;
                        extractCellLayoutStyle(cellRef, jsonObject, appendExtra);
                    }
                }
                v0 = true;
            } catch (Exception exception) {
                Logger.e("CellRef", "exception in extractAppAd : " + exception.toString());
            }
        }

        return v0;
    }

    public final long getAdId() {
        long v0 = 0;
        switch (this.cellType) {
            case 0: {
                if (this.adId <= v0) {
                    return v0;
                }

                v0 = this.adId;
                break;
            }
            case 9:
            case 10:
            case 16:
            case 30: {
                v0 = this.adId;
                break;
            }
        }

        return v0;
    }

    public static boolean extractActionAd(CellRef cellRef, JSONObject jsonObject, boolean arg9) {
        if (cellRef != null && jsonObject != null) {
            if (cellRef.cellType != 16) {
                if (cellRef.cellType != 0) {
                    return false;
                }
            }

            try {
                int displayType = jsonObject.optInt("display_type");
                if (!FeedCallAppAd.a(displayType)) {
                    return false;
                }

                FeedCallAppAd feedCallAppAd = new FeedCallAppAd(displayType);
                feedCallAppAd.initWithJO(jsonObject);
                extractSourceIcon(cellRef, jsonObject, arg9);
                extractSourceOpenUrl(cellRef, jsonObject);
                extractSourceAvatar(cellRef, jsonObject);
                extractFilterWords(cellRef, jsonObject, arg9);
                appendExtraData(cellRef, jsonObject);
                if (!feedCallAppAd.isValid()) {
                    return false;
                }

                cellRef.adId = feedCallAppAd.id;
                cellRef.feedCallAppAd = feedCallAppAd;
                if (cellRef.cellType == 16) {
                    String adId = cellRef.adId > 0 ? String.valueOf(cellRef.adId) : "";
                    cellRef.cellId = adId;
                    cellRef.cateBehotTime = jsonObject.optLong("behot_time");
                    cellRef.appendExtraData = jsonObject.toString();
                    cellRef.logExtra = jsonObject.optString("log_extra");
                    cellRef.actionExtra = jsonObject.optString("action_extra");
                    extractCellLayoutStyle(cellRef, jsonObject, arg9);
                } else {
                    if (cellRef.cellType != 0) {
                    } else {
                        appendExtraData(cellRef, "ad_data", jsonObject.toString());
                        cellRef.Q = 3;
                        cellRef.feedCallAppAd.actionType = 1;
                        extractCellLayoutStyle(cellRef, jsonObject, arg9);
                    }
                }
                return true;
            } catch (Exception e) {
                Logger.e("CellRef", "exception in extractActionAd : " + e.toString());
            }
        }

        return false;
    }

    private static boolean extractStickStyle(CellRef cellRef, JSONObject jsonObject) {
        if (cellRef == null || jsonObject == null) {
            return false;
        } else {
            if (jsonObject.has("stick_style")) {
                cellRef.stickStyle = jsonObject.optInt("stick_style");
                appendExtraData(cellRef, "stick_style", cellRef.stickStyle);
            } else {
                cellRef.stickStyle = -1;
            }
            return true;
        }
    }

    public final boolean e() {
        return this.cellType == 25;
    }

    public static boolean extractLbsAd(CellRef cellRef, JSONObject jsonObject, boolean arg8) {
        boolean v0 = false;
        if (cellRef != null && (jsonObject != null && cellRef.cellType == 30)) {
            try {
                AdsData v1_1 = new AdsData();
                v1_1.initWithJO(jsonObject);
                if (!v1_1.isValid()) {
                    return v0;
                }

                cellRef.adId = v1_1.id;
                cellRef.embeddedAd = v1_1;
                String v1_2 = cellRef.adId > 0 ? String.valueOf(cellRef.adId) : "";
                cellRef.cellId = v1_2;
                cellRef.cateBehotTime = jsonObject.optLong("behot_time");
                cellRef.appendExtraData = jsonObject.toString();
                cellRef.logExtra = jsonObject.optString("log_extra");
                cellRef.actionExtra = jsonObject.optString("action_extra");
                extractCellLayoutStyle(cellRef, jsonObject, arg8);
                extractSourceIcon(cellRef, jsonObject, arg8);
                extractSourceOpenUrl(cellRef, jsonObject);
                extractSourceAvatar(cellRef, jsonObject);
                extractFilterWords(cellRef, jsonObject, arg8);
                appendExtraData(cellRef, jsonObject);
                extractStickStyle(cellRef, jsonObject);
                extractStickLabel(cellRef, jsonObject);
                cellRef.reason = jsonObject.optString("reason");
                cellRef.recommendUrl = jsonObject.optString("recommend_url");
                cellRef.source = jsonObject.optString("source");
                cellRef.sourceDesc = jsonObject.optString("source_desc");
                cellRef.sourceDescOpenUrl = jsonObject.optString("source_desc_open_url");
                cellRef.subTitle = jsonObject.optString("sub_title");
                cellRef.actionList = JsonUtil.a(jsonObject.optJSONArray("action_list"), b.class);
                cellRef.sourceIconStyle = jsonObject.optInt("source_icon_style");
                cellRef.isSubscribe = jsonObject.optBoolean("is_subscribe", false);
                cellRef.verifiedContent = jsonObject.optString("verified_content");
                cellRef.userVerified = jsonObject.optInt("user_verified");
                cellRef.readCount = jsonObject.optInt("read_count");
                String v2 = cellRef.appendExtraData;
                JSONObject v1_3 = null;
                try {
                    if (!android.support.design.a.isTextEmpty(v2)) {
                        v1_3 = new JSONObject(v2);
                    }

                    if (v1_3 == null) {
                        v1_3 = new JSONObject();
                    }

                    if (jsonObject == null || (jsonObject.has("reason"))) {
                        v1_3.put("reason", cellRef.reason);
                    }

                    if (jsonObject == null || (jsonObject.has("recommend_url"))) {
                        v1_3.put("recommend_url", cellRef.recommendUrl);
                    }

                    if (jsonObject == null || (jsonObject.has("source"))) {
                        v1_3.put("source", cellRef.source);
                    }

                    if (jsonObject == null || (jsonObject.has("is_subscribe"))) {
                        v1_3.put("is_subscribe", cellRef.isSubscribe);
                    }

                    if (jsonObject == null || (jsonObject.has("source_desc"))) {
                        v1_3.put("source_desc", cellRef.sourceDesc);
                    }

                    if (jsonObject == null || (jsonObject.has("source_desc_open_url"))) {
                        v1_3.put("source_desc_open_url", cellRef.sourceDescOpenUrl);
                    }

                    if (jsonObject == null || (jsonObject.has("sub_title"))) {
                        v1_3.put("sub_title", cellRef.subTitle);
                    }

                    if (jsonObject == null || (jsonObject.has("action_list"))) {
                        v1_3.put("action_list", JsonUtil.b(cellRef.actionList));
                    }

                    if (jsonObject == null || (jsonObject.has("source_icon_style"))) {
                        v1_3.put("source_icon_style", cellRef.sourceIconStyle);
                    }

                    if (jsonObject == null || (jsonObject.has("read_count"))) {
                        v1_3.put("read_count", cellRef.readCount);
                    }

                    cellRef.appendExtraData = v1_3.toString();
                } catch (JSONException v1_4) {
                    try {
                        Logger.d("CellRef", "exception in appendExtraData : " + v1_4.toString());
                    } catch (Exception v1) {
                        Logger.e("CellRef", "exception in extractLbsAd : " + v1.toString());
                        return v0;
                    }
                }
            } catch (Exception v1) {
                Logger.e("CellRef", "exception in extractLbsAd : " + v1.toString());
                return v0;
            }

            v0 = true;
        }

        return v0;
    }

    private static boolean extractStickLabel(CellRef cellRef, JSONObject jsonObject) {
        if (cellRef == null || jsonObject == null) {
            return false;
        } else {
            if (jsonObject.has("stick_label")) {
                cellRef.stickLabel = jsonObject.optString("stick_label", "");
                appendExtraData(cellRef, "stick_label", cellRef.stickLabel);
            } else {
                cellRef.stickLabel = "";
            }
            return true;
        }
    }

    public final boolean equals(Object arg5) {
        boolean v0 = true;
        if (this != arg5) {
            if (arg5 != null && this.getClass() == arg5.getClass()) {
                if (this.cellType != ((CellRef) arg5).cellType) {
                    v0 = false;
                } else {
                    if (this.cellId != null) {
                        if (this.cellId.equals(((CellRef) arg5).cellId)) {
                            return v0;
                        }
                    } else if (((CellRef) arg5).cellId == null) {
                        return v0;
                    }

                    v0 = false;
                }

                return v0;
            }

            v0 = false;
        }

        return v0;
    }

    public final boolean f() {
        if (this.article == null || !this.article.h() || this.article.largeImageList == null) {
            return false;
        } else {
            return this.videoStyle == 3 || this.videoStyle == 4
                    || this.videoStyle == 6 || this.videoStyle == 7
                    || this.videoStyle == 8 || this.videoStyle == 12
                    || this.videoStyle == 9;

        }
    }

    private static boolean appendExtraData(CellRef cellRef, JSONObject jsonObject) {
        if (cellRef != null && jsonObject != null) {
            if (jsonObject.has("is_stick")) {
                cellRef.isStick = jsonObject.optBoolean("is_stick");
                boolean isStick = cellRef.isStick;
                if (cellRef == null) {
                    return true;
                }

                String appendExtraData = cellRef.appendExtraData;
                JSONObject jsonObject2 = null;
                try {
                    if (!android.support.design.a.isTextEmpty(appendExtraData)) {
                        jsonObject2 = new JSONObject(appendExtraData);
                    }
                    if (jsonObject2 == null) {
                        jsonObject2 = new JSONObject();
                    }
                    jsonObject2.put("is_stick", isStick);
                    cellRef.appendExtraData = jsonObject2.toString();
                } catch (JSONException jsonException) {
                    Logger.d("CellRef", "exception in appendExtraData : " + jsonException.toString());
                }
            } else {
                cellRef.isStick = false;
            }
            return true;
        }
        return false;
    }

    private static void extractCellLayoutStyle(CellRef cellRef, JSONObject jsonObject, boolean appendExtraData) {
        if (cellRef != null && jsonObject != null) {
            if ((com.ss.android.article.base.utils.c.a.a()) || (Logger.debug())) {
                AppData.getInstance();
            }

            cellRef.cellFlag = jsonObject.optInt("cell_flag", 267);
            cellRef.cellLayoutStyle = jsonObject.optInt("cell_layout_style", 1);
            if (!appendExtraData) {
                return;
            }
            appendExtraData(cellRef, "cell_flag", cellRef.cellFlag);
            appendExtraData(cellRef, "cell_layout_style", cellRef.cellLayoutStyle);
        }
    }

    public final boolean g() {
        int v2 = this.videoStyle == 2
                || this.videoStyle == 3
                || this.videoStyle == 4
                || this.videoStyle == 5
                || this.videoStyle == 6
                || this.videoStyle == 7
                || this.videoStyle == 8
                || this.videoStyle == 12
                || this.videoStyle == 9 ? 1 : 0;
        return v2 != 0 && this.article != null && this.article.h() && this.article.largeImageList != null;
    }

    private static boolean extractSourceIcon(CellRef cellRef, JSONObject jsonObject, boolean isJO) {
        if (cellRef != null && jsonObject != null) {
            cellRef.sourceIcon = null;
            cellRef.sourceIconNight = null;
            try {

                if (jsonObject.has("source_icon")) {
                    JSONObject sourceIconJO = isJO
                            ? jsonObject.getJSONObject("source_icon")
                            : new JSONObject(jsonObject.optString("source_icon"));
                    cellRef.sourceIcon = ImageInfo.fromJson(sourceIconJO, false);
                    appendExtraData(cellRef, "source_icon", sourceIconJO.toString());
                }

                if (jsonObject.has("source_icon_night")) {
                    JSONObject sourceIconJO = isJO
                            ? jsonObject.getJSONObject("source_icon_night")
                            : new JSONObject(jsonObject.optString("source_icon_night"));
                    cellRef.sourceIconNight = ImageInfo.fromJson(sourceIconJO, false);
                    appendExtraData(cellRef, "source_icon_night", sourceIconJO.toString());
                }
                return true;
            } catch (JSONException jsonException) {
                Logger.e("CellRef", "exception in extractSourceIcon : " + jsonException.toString());
            }
        }
        return false;
    }

    private static boolean extractSourceOpenUrl(CellRef cellRef, JSONObject jsonObject) {
        if (cellRef == null || jsonObject == null) {
            return false;
        } else {
            if (jsonObject.has("source_open_url")) {
                cellRef.sourceOpenUrl = jsonObject.optString("source_open_url");
                appendExtraData(cellRef, "source_open_url", cellRef.sourceOpenUrl);
            }
            return true;
        }
    }

    public final boolean h() {
        return (!this.p()) && (this.cellFlag & 256) > 0;
    }

    private static void extractFilterWords(CellRef cellRef, JSONObject jsonObject, boolean appendExtra) {
        JSONArray filterWordsJA;
        if (cellRef != null && jsonObject != null) {
            try {
                boolean showDislike = !jsonObject.has("show_dislike") || (jsonObject.optBoolean("show_dislike"));
                cellRef.showDislike = showDislike;
                long adFetchTime = appendExtra ? System.currentTimeMillis() / 1000 : jsonObject.optLong("ad_fetch_time");
                cellRef.adFetchTime = adFetchTime;
                long expireSeconds = 0;
                if (jsonObject.optLong("expire_seconds") > expireSeconds) {
                    expireSeconds = jsonObject.optLong("expire_seconds");
                }

                cellRef.expireSeconds = expireSeconds;
                boolean adHasExpire = (appendExtra) || jsonObject.optInt("ad_has_expire") <= 0 ? false : true;
                cellRef.adHasExpire = adHasExpire;
                appendExtraData(cellRef, "show_dislike", String.valueOf(cellRef.showDislike));
                appendExtraData(cellRef, "expire_seconds", cellRef.expireSeconds);
                appendExtraData(cellRef, "ad_fetch_time", cellRef.adFetchTime);
                appendExtraData(cellRef, "ad_has_expire", cellRef.adHasExpire ? 1 : 0);
                JSONArray ja = null;
                if (!appendExtra) {
                    String filterWords = jsonObject.optString("filter_words");
                    if (!android.support.design.a.isTextEmpty(filterWords)) {
                        ja = new JSONArray(filterWords);
                    }
                    filterWordsJA = ja;
                } else {
                    filterWordsJA = jsonObject.optJSONArray("filter_words");
                }

                if (filterWordsJA == null) {
                    return;
                }

                if (filterWordsJA.length() <= 0) {
                    return;
                }

                cellRef.filterWordList.clear();
                for (int i = 0; i < filterWordsJA.length(); ++i) {
                    JSONObject filterWordJO = filterWordsJA.optJSONObject(i);
                    if (filterWordJO != null) {
                        String id = filterWordJO.optString("id");
                        String name = filterWordJO.optString("name");
                        boolean isSelected = filterWordJO.optBoolean("is_selected");
                        if (!android.support.design.a.isTextEmpty(id)
                                && !android.support.design.a.isTextEmpty(name)) {
                            cellRef.filterWordList.add(new FilterWord(id, name, isSelected));
                        }
                    }
                }
                appendExtraData(cellRef, "filter_words", filterWordsJA.toString());
            } catch (Exception v0_1) {
                Logger.e("CellRef", "exception in extractFilterWords : " + v0_1.toString(), ((Throwable) v0_1));
            }
        }
    }

    private static boolean extractSourceAvatar(CellRef cellRef, JSONObject jsonObject) {
        if (cellRef == null || jsonObject == null) {
            return false;
        } else {
            if (jsonObject.has("source_avatar")) {
                String source_avatar = jsonObject.optString("source_avatar");
                cellRef.sourceAvatar = source_avatar;
                appendExtraData(cellRef, "source_avatar", source_avatar);
            }
            return true;
        }
    }

    public final int hashCode() {
        int v1 = this.cellType * 31;
        int v0 = this.cellId != null ? this.cellId.hashCode() : 0;
        return v0 + v1;
    }

    public final boolean i() {
        return (!this.p()) && (this.cellFlag & 1) > 0;
    }

    public final boolean j() {
        return this.cellLayoutStyle == 4;
    }

    public final boolean k() {
        boolean v0 = false;
        if (AppData.getInstance().getAppSettings().mPlayVideoInFeed == 0 && (this.cellFlag & 64) > 0) {
            v0 = true;
        }

        return v0;
    }

    public final boolean l() {
        boolean v0 = (this.cellFlag & 512) > 0 ? true : false;
        return v0;
    }

    public final boolean m() {
        boolean v0 = (this.p()) || (this.cellFlag & 2) <= 0 ? false : true;
        return v0;
    }

    public final boolean n() {
        boolean v0 = (this.p()) || (this.cellFlag & 8) <= 0 ? false : true;
        return v0;
    }

    public final boolean o() {
        boolean v0 = !this.p() ? true : false;
        return v0;
    }

    public final boolean p() {
        boolean v0 = false;
        if (this.cellType == 0 && this.article != null && (this.adId <= 0 || this.Q == 0) && (this.cellFlag & 4) > 0 && !android.support.design.a.isTextEmpty(this.article.reason)) {
            v0 = true;
        }

        return v0;
    }

    public final boolean q() {
        boolean v0 = (this.cellFlag & 1024) > 0 ? true : false;
        return v0;
    }

    public final boolean r() {
        boolean v0 = this.filterWordList.size() > 0 ? true : false;
        return v0;
    }
}

